import{M as e,S as t,L as i,a as o,A as s,D as n,b as a,P as r,c as l,_ as h,d as c,e as d,I as u,B as p,f as m,g as _,h as f,i as g,j as w,k as v,l as b,s as y,m as k,n as C,H as S,F as M,o as x,p as T,q as E,r as A,u as L,t as O,v as I,w as V,x as P,y as j,z as $,C as U,E as W,G as z,J as N,K as F,N as D,O as q,Q as B,R as H,T as R,U as K,V as G,W as Y,X as Q,Y as J,Z as X,$ as Z,a0 as ee,a1 as te,a2 as ie,a3 as oe,a4 as se,a5 as ne,a6 as ae,a7 as re,a8 as le,a9 as he,aa as ce,ab as de,ac as ue,ad as pe,ae as me,af as _e,ag as fe,ah as ge,ai as we,aj as ve,ak as be,al as ye,am as ke,an as Ce,ao as Se,ap as Me,aq as xe,ar as Te,as as Ee,at as Ae,au as Le,av as Oe,aw as Ie,ax as Ve,ay as Pe,az as je,aA as $e,aB as Ue,aC as We,aD as ze,aE as Ne,aF as Fe,aG as De,aH as qe,aI as Be,aJ as He,aK as Re,aL as Ke,aM as Ge,aN as Ye,aO as Qe,aP as Je,aQ as Xe,aR as Ze,aS as et,aT as tt,aU as it,aV as ot,aW as st,aX as nt,aY as at,aZ as rt,a_ as lt,a$ as ht,b0 as ct,b1 as dt,b2 as ut,b3 as pt,b4 as mt,b5 as _t,b6 as ft,b7 as gt,b8 as wt,b9 as vt,ba as bt}from"./chunk.common_CTPs4D8t.esm.js";class yt extends e{constructor({elementName:e,analyticsTraceId:i}){super({elementName:e,analyticsTraceId:i,flow:t})}trackFollowButtonPageImpression(e){this.trackPageImpression({page:e?i.ComponentLoadedFollowing:i.ComponentLoadedNotFollowing})}trackFollowButtonInViewport(){this.trackPageImpression({page:i.FollowButtonShownInViewport})}trackFollowingGetAppButtonPageImpression(){this.trackPageImpression({page:i.FollowingGetShopAppCta})}trackFollowButtonClicked(){this.trackShopPayLoginWithShopSdkUserAction({userAction:o.FollowOnShopClicked})}trackFollowingGetAppButtonClicked(){this.trackShopPayLoginWithShopSdkUserAction({userAction:o.FollowingGetShopAppClick})}}class kt extends e{constructor({elementName:e,analyticsTraceId:t,analyticsContext:i=n.Default,flowVersion:o="unspecified",checkoutVersion:a,checkoutToken:r,shopId:l,shopPermanentDomain:h}){super({elementName:e,analyticsTraceId:t,flow:s[i],flowVersion:o,checkoutVersion:a,checkoutToken:r,shopId:l,shopPermanentDomain:h}),this._emailEnteredUserActionTracked=!1,this._passwordManagerAutofillDetected=!1}trackLoginDefaultButtonClicked(){this.trackShopPayLoginWithShopSdkUserAction({userAction:o.SignInWithShopClicked})}trackEmailEnteredAction(){this._emailEnteredUserActionTracked||(this._emailEnteredUserActionTracked=!0,this.trackShopPayLoginWithShopSdkUserAction({userAction:o.EmailEntered}))}trackPasswordManagerAutofillDetected(){this._passwordManagerAutofillDetected||(this._passwordManagerAutofillDetected=!0,this.trackShopPayLoginWithShopSdkUserAction({userAction:o.PasswordManagerAutofillDetected}))}trackFedCMCancelledUserAction(){this.trackShopPayLoginWithShopSdkUserAction({userAction:o.FedCmCancelled})}trackFedCMCompletedUserAction(){this.trackShopPayLoginWithShopSdkUserAction({userAction:o.FedCmCompleted})}}class Ct extends kt{constructor({elementName:e,flowVersion:t,analyticsTraceId:i}){super({elementName:e,analyticsTraceId:i,analyticsContext:n.ClassicCustomerAccounts,flowVersion:t})}trackClassicCustomerAccountsLoginPageImpression(){this.trackPageImpression({page:i.ClassicCustomerAccountLogin})}trackClassicCustomerAccountsCreateAccountPageImpression(){this.trackPageImpression({page:i.ClassicCustomerAccountCreateAccount})}trackClassicCustomerAccountsAccountPageImpression(){this.trackPageImpression({page:i.ClassicCustomerAccount})}trackClassicCustomerAccountsContinueWithShopPageImpression(){this.trackPageImpression({page:i.ContinueWithShop})}trackClassicCustomerAccountsCreateAccountAction(){this.trackShopPayLoginWithShopSdkUserAction({userAction:o.CreateAccountLinkClicked})}}const St=window.location.origin,Mt=()=>St,xt=({version:e,apiKey:t,analyticsTraceId:i,analyticsContext:o,isCompactLayout:s,isFullView:n,flow:l,flowVersion:h,signUpEnabled:c,oauthParams:d,avoidPayAltDomain:u,avoidSdkSession:p,hideCopy:m,modalCustomized:_,popupWindowParams:f,consentChallenge:g,checkoutRedirectUrl:w,checkoutVersion:v,checkoutToken:b,transactionParams:y,shopId:k,requireVerification:C,uxMode:S,error:M})=>"1"===e||"redirect"===S?function(e){return Boolean(void 0!==e&&"clientId"in e&&(null==e?void 0:e.clientId))}(d)?(({oauthParams:e,analyticsTraceId:t,analyticsContext:i,isCompactLayout:o,isFullView:s,flow:n,flowVersion:l,signUpEnabled:h,avoidPayAltDomain:c,hideCopy:d,modalCustomized:u,apiKey:p,popupWindowParams:m,consentChallenge:_,checkoutVersion:f,checkoutToken:g,transactionParams:w,shopId:v,requireVerification:b,uxMode:y,error:k})=>{const{clientId:C,redirectType:S}=e,M=e.scope||"openid email profile",x=e.responseType||"id_token",T=e.responseMode||"web_message",E=e.redirectUri||window.location.origin,{popUpName:A,popUpFeatures:L}=m||{},O="redirect"!==y&&d,I=new URLSearchParams(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({target_origin:window.location.origin,response_mode:T,response_type:x,scope:M,version:"1",client_id:C},S&&{redirect_type:S}),{redirect_uri:E,locale:"en"}),t&&{analytics_trace_id:t}),i&&{analytics_context:i}),a("compact_layout",o)),p&&{apiKey:p}),n&&{flow:n}),l&&{flow_version:l}),e.codeChallenge&&{code_challenge:e.codeChallenge}),e.codeChallengeMethod&&{code_challenge_method:e.codeChallengeMethod}),e.state&&{state:e.state}),f&&{checkout_version:f}),g&&{checkout_token:g}),w&&{transaction_params:w}),v&&{shop_id:v}),k&&{error:k}),a("full_view",s)),a("sign_up_enabled",h)),a("hide_copy",O)),a("customize-modal",u)),a("consent_challenge",_)),a("require_verification",b)),a("preact",!1)),"pop_up"===S?{pop_up_name:A,pop_up_features:L}:{}));return`${r}${c?"/pay/sdk-authorize":"/pay/sdk-session"}?${I}`})({popupWindowParams:f,oauthParams:d,analyticsTraceId:i,analyticsContext:o,isCompactLayout:s,isFullView:n,flow:l,flowVersion:h,signUpEnabled:c,avoidPayAltDomain:u,hideCopy:m,modalCustomized:_,apiKey:t,consentChallenge:g,checkoutVersion:v,checkoutToken:b,transactionParams:y,shopId:k,requireVerification:C,uxMode:S,error:M}):"":(({analyticsTraceId:e,analyticsContext:t,isCompactLayout:i,isFullView:o,flow:s,flowVersion:n,signUpEnabled:r,avoidSdkSession:l,hideCopy:h,modalCustomized:c,apiKey:d,consentChallenge:u,checkoutRedirectUrl:p,checkoutVersion:m,checkoutToken:_,transactionParams:f,shopId:g,requireVerification:w,oauthParams:v,error:b})=>{const y=new URLSearchParams(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({target_origin:window.location.origin,api_key:null!=d?d:"123",locale:"en"},e&&{analytics_trace_id:e}),t&&{analytics_context:t}),a("compact_layout",i)),s&&{flow:s}),n&&{flow_version:n}),p&&{checkout_redirect_url:p}),m&&{checkout_version:m}),_&&{checkout_token:_}),f&&{transaction_params:f}),g&&{shop_id:g}),b&&{error:b}),a("full_view",o)),a("sign_up_enabled",r)),a("avoid_sdk_session",l)),a("hide_copy",h)),a("customize-modal",c)),a("consent_challenge",u)),a("require_verification",w)),a("preact",!1)),(null==v?void 0:v.responseType)&&{response_type:v.responseType}),(null==v?void 0:v.redirectType)&&{redirect_type:v.redirectType}));return`${St}/services/login_with_shop/authorize?${y}`})({analyticsTraceId:i,analyticsContext:o,isCompactLayout:s,isFullView:n,flow:l,flowVersion:h,signUpEnabled:c,avoidSdkSession:p,hideCopy:m,modalCustomized:_,apiKey:t,consentChallenge:g,checkoutRedirectUrl:w,checkoutVersion:v,checkoutToken:b,transactionParams:y,shopId:k,requireVerification:C,oauthParams:d,error:M});var Tt,Et,At,Lt;class Ot extends HTMLElement{constructor(){super(),Tt.add(this),Et.set(this,null),At.set(this,null),customElements.get("shop-logo")||customElements.define("shop-logo",l)}connectedCallback(){return h(this,void 0,void 0,(function*(){if(yield c(this,Tt,"m",Lt).call(this),this.shadowRoot)return;const e=document.createElement("template");if(e.innerHTML=`\n \n \n `,d(this,Et,this.attachShadow({mode:"open"}),"f"),c(this,Et,"f").appendChild(e.content.cloneNode(!0)),c(this,At,"f")){const e=c(this,At,"f").translate("login_with_shop.login",{shop:It("white")});c(this,Et,"f").querySelector('slot[name="login-text"]').innerHTML=e}}))}setFocused(){var e,t;null===(t=null===(e=c(this,Et,"f"))||void 0===e?void 0:e.querySelector("button"))||void 0===t||t.focus()}}function It(e){return``}Et=new WeakMap,At=new WeakMap,Tt=new WeakSet,Lt=function(){return h(this,void 0,void 0,(function*(){try{const e="en",t={follow_on_shop:{follow:"Follow on {shop}",following:"Following on {shop}",auth_modal:{title:"Follow on Shop",description:"Stay in the know—never miss a sale, restock, or order update."},following_modal:{title:"Visit {store} on Shop",subtitle:"Everything you need to shop, track, and pay—all in one place.",qr_header:"Scan to visit {store} on the Shop app",qr_alt_text:"Shop app QR code",continue:"Continue"},completed:{title:"You're following {store}",subtitle:"We've sent you an email with a link to download the Shop app."},personalization_consent:{title:"To follow on Shop, sync your shopping activity"}},login_with_shop:{login:"Sign in with {shop}",auth_modal:{login_title:"Sign in with Shop",login_title_with_store:"Sign in to {store} with Shop",login_description:"The easiest and most secure way to sign in to {store}—no password needed.",signup_title:"Create an account",signup_description:"Enter your phone number to create a Shop account.",login_sms_title:"Confirm it's you",login_sms_description:"Enter the code sent to {phoneNumber}",login_email_title:"Confirm it’s you",login_email_description:"Enter the code sent to your email, {email}",login_webauthn_title:"Confirm it’s you",login_webauthn_description:"Sign in with a passkey to securely use your saved information.",login_webauthn_footer:"By continuing, your name and email address will be shared with {store}."}},verified_email_auth:{auth_modal:{login_title:"Log in or sign up",signup_title:"Continue with Shop",signup_description:"Create a Shop account to sign in to {clientName}–no passwords needed"}},legal:{terms_of_service:"terms of service",privacy_policy:"privacy policy",terms:"terms",client:"See {clientName}’s {termsOfService} and {privacyPolicy}.",shop:"By continuing, you agree to Shop’s {termsOfService} and acknowledge the {privacyPolicy}.",authorized_scopes:{email_name:"By continuing, your name and email address will be shared with {store}."}},checkout_modal:{auth_modal:{login_sms_description:"Enter the code sent to {phoneNumber} to securely use your saved information.",login_email_description:"Enter the code sent to your email, {email} to securely use your saved information."}},customer_accounts:{remember_me:"Save my info securely with Shop to sign in faster everywhere",sign_up_page:{auth_modal:{login_title:"Continue with Shop",login_description:"Use your Shop account to sign in everywhere—no password needed.",login_sms_description:"Use your Shop account to sign in everywhere—no password needed.\r\n\r\nConfirm it's you, enter the code sent to {phoneNumber}",login_email_description:"Use your Shop account to sign in everywhere—no password needed.\r\n\r\nConfirm it's you, enter the code sent to your email, {email}",login_webauthn_title:"Continue with Shop",login_webauthn_description:"Sign in with a passkey to securely use your saved information."}}},payment_request:{auth_modal:{login_title:"Check out with Shop Pay",login_description:"Use your saved information to check out securely at {store}.",login_sms_title:"Confirm it's you",login_sms_description:"Enter the code sent to {phoneNumber} to securely use your saved information.",login_email_title:"Confirm it’s you",login_email_description:"Enter the code sent to your email, {email} to securely use your saved information."}}};d(this,At,new u({[e]:t}),"f")}catch(e){e instanceof Error&&p.notify(e)}return null}))},customElements.get("login-with-shop-button")||customElements.define("login-with-shop-button",Ot);function Vt(e){if(!g.isSupported)throw new Error("Sanitization of custom modal text is not supported in this browser.");return g.sanitize(e,{ALLOWED_TAGS:[]})}const Pt={step:w.Start,configurable:!1,headerVisible:!1,headerDividerVisible:!1,headerTemplate:"",descriptionTemplate:"",userNameKnown:!1,sessionDetected:!1,templateVariables:{clientName:"the store",store:"the store"}};function jt(e,t){switch(e.type){case v.Init:return e.payload.personalizeConsentChallenge?Object.assign(Object.assign({},t),{step:w.PersonalizeConsent,headerVisible:!0,headerDividerVisible:!1,userNameKnown:e.payload.userNameKnown||!1,templateVariables:Object.assign(Object.assign(Object.assign({},t.templateVariables),e.payload),{store:e.payload.clientName}),headerTemplate:"login_with_shop.auth_modal.login_title_with_store",descriptionTemplate:"",sessionDetected:e.payload.userFound}):Object.assign(Object.assign({},t),{configurable:!0,headerVisible:!0,headerDividerVisible:e.payload.userFound,step:e.payload.userFound?w.OneClick:w.Start,userNameKnown:e.payload.userNameKnown||!1,templateVariables:Object.assign(Object.assign(Object.assign({},t.templateVariables),e.payload),{store:e.payload.clientName}),headerTemplate:"login_with_shop.auth_modal.login_title",descriptionTemplate:"login_with_shop.auth_modal.login_description",sessionDetected:e.payload.userFound});case v.PopUpOpened:return Object.assign(Object.assign({},t),{step:w.PopUpOpened});case v.Restart:return Object.assign(Object.assign({},t),{configurable:!0,headerDividerVisible:!1,step:w.Start,userNameKnown:!1,headerTemplate:"login_with_shop.auth_modal.login_title",descriptionTemplate:"login_with_shop.auth_modal.login_description",sessionDetected:!1,templateVariables:Object.assign(Object.assign({},t.templateVariables),{email:"",phoneNumber:"",userFound:!1,userNameKnown:!1})});case v.UserMatched:return e.payload.personalizeConsentChallenge?Object.assign(Object.assign({},t),{step:w.PersonalizeConsent,userNameKnown:e.payload.hasName||!1,headerVisible:!0,headerDividerVisible:!1,headerTemplate:"login_with_shop.auth_modal.login_title_with_store",descriptionTemplate:"",sessionDetected:e.payload.userCookieExists}):e.payload.userCookieExists?Object.assign(Object.assign({},t),{configurable:!0,headerDividerVisible:!0,step:w.OneClick,userNameKnown:e.payload.hasName||!1,sessionDetected:!0}):Object.assign(Object.assign({},t),{userNameKnown:e.payload.hasName||!1,sessionDetected:!1});case v.UserNotMatched:return Object.assign(Object.assign({},t),{step:w.SignUp,headerDividerVisible:!0,userNameKnown:!1,configurable:!1,headerTemplate:"login_with_shop.auth_modal.signup_title",descriptionTemplate:"login_with_shop.auth_modal.signup_description",sessionDetected:!1});case v.VerificationStepChanged:{const{step:i,phone:o="",email:s=""}=e.payload;return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},t),{step:$t(i),configurable:!1,headerDividerVisible:!0,templateVariables:Object.assign(Object.assign({},t.templateVariables),{phoneNumber:"windows-1252"===document.characterSet.toLowerCase()?o:o.replaceAll(" "," "),email:s}),legalTextVariant:"authorize"}),"email"===i&&{headerTemplate:"login_with_shop.auth_modal.login_email_title",descriptionTemplate:"login_with_shop.auth_modal.login_email_description"}),"sms"===i&&{headerTemplate:"login_with_shop.auth_modal.login_sms_title",descriptionTemplate:"login_with_shop.auth_modal.login_sms_description"}),"one_click"===i&&{headerTemplate:"login_with_shop.auth_modal.login_title",descriptionTemplate:"login_with_shop.auth_modal.login_description"}),"webauthn"===i&&{headerTemplate:"login_with_shop.auth_modal.login_webauthn_title",descriptionTemplate:"login_with_shop.auth_modal.login_webauthn_description",legalTextVariant:"generic",legalTextTemplate:"login_with_shop.auth_modal.login_webauthn_footer",headerDividerVisible:!1})}}return t}function $t(e){switch(e){case"one_click":return w.OneClick;case"email":return w.EmailVerification;case"webauthn":return w.WebAuthnVerification;default:return w.PhoneVerification}}class Ut{get _sheetModal(){return this._sheetModalManager.sheetModal}constructor(e,t){this._isCompact=!1,this._isHeaderless=!1,this._analyticsContext=n.Default,this._flowVersion="unspecified",this._authenticationLevel=b.Phone,this._state=Pt,this._rootElement=e,this._sheetModalManager=y().build(),({onOpen:this._onOpen,onClose:this._onClose}=t)}setCompact(e){this._isCompact=e}setHeaderless(e){this._isHeaderless=e}init(){var e,t,i,o;const s=this.getModalAttributes();k(C(s),"shop-login-default-landing",this._sheetModalManager.shadowRoot),this._modalHeader=this._sheetModalManager.shadowRoot.querySelector(`.${S}`),this._footerElement=this._sheetModalManager.shadowRoot.querySelector(`.${M}`),this._footerContent=this._sheetModalManager.shadowRoot.querySelector(`.${x}`),this._iframe=this._sheetModalManager.shadowRoot.querySelector(`.${T}`),this._sheetModal.addEventListener("modalcloserequest",(()=>h(this,void 0,void 0,(function*(){yield this.closeAuthorizeModal({modalStateChangeReason:"user_dismissed"})})))),this._isCompact&&(this._sheetModal.setAttribute(E,""),this._sheetModal.setMonorailTracker(this._monorailTracker),this._iframe.classList.add(A),null===(t=null===(e=this._modalHeader)||void 0===e?void 0:e.parentNode)||void 0===t||t.removeChild(this._modalHeader),null===(o=null===(i=this._footerElement)||void 0===i?void 0:i.parentNode)||void 0===o||o.removeChild(this._footerElement)),L(this._iframe,"allow","publickey-credentials-get *")}setModalAnalyticsTraceId(e){this._sheetModal.setAttribute(O,e)}showModal(e){return h(this,void 0,void 0,(function*(){(yield this._sheetModal.open(e))&&this._onOpen(),this.refreshHeaderIframeHeight()}))}openAuthorizeModal(e){return h(this,void 0,void 0,(function*(){var t;yield this.showModal(e),yield null===(t=this._monorailTracker)||void 0===t?void 0:t.trackPageImpression({page:i.AuthorizeModal})}))}closeAuthorizeModal(){return h(this,arguments,void 0,(function*({modalStateChangeReason:e}={}){var t;if(this._sheetModal){(yield this._sheetModal.close({reason:e}))&&this._onClose()}null===(t=this._continueButton)||void 0===t||t.setFocused()}))}destroy(){this._sheetModalManager.destroy()}setContinueButtonVisible(e){var t,o,s;if(!e)return null===(t=this._continueButton)||void 0===t||t.remove(),void(this._continueButton=void 0);this._continueButton||(this._continueButton=document.createElement("login-with-shop-button"),null===(o=this._continueButton)||void 0===o||o.addEventListener("click",(()=>{var e;null===(e=this._monorailTracker)||void 0===e||e.trackLoginDefaultButtonClicked(),"redirect"===this._uxMode&&this._authorizeUrl?window.location.href=this._authorizeUrl:this.openAuthorizeModal("user_button_clicked")})),null===(s=this._monorailTracker)||void 0===s||s.trackPageImpression({page:i.SignInWithShopButton}),this._rootElement.appendChild(this._continueButton))}setMonorailTracker(e){var t,i;this._monorailTracker=e,null===(i=(t=this._sheetModal).setMonorailTracker)||void 0===i||i.call(t,e)}setAnalyticsContext(e){this._analyticsContext=e}setFlowVersion(e){this._flowVersion=e}getUxMode(){return this._uxMode}setUxMode(e){e&&(this._uxMode=e)}setAuthorizeUrl(e){this._authorizeUrl=e}setAuthenticationLevel(e){this._authenticationLevel=e}onContentLoaded(){this._sheetModal.onContentLoaded()}setFlow(e){this._flow=e,this._sheetModalManager.setNametagSuffix(e)}getIframe(){return this._iframe}setAnchorSelector(e){this._sheetModal.setAttribute(I,e)}setBrand(e){e&&this._sheetModal.setAttribute("modal-brand",e)}resizeIframe(e,t){this._iframe&&(this._iframe.style.height=`${e}px`,this._iframe.style.width=`${V(t,this._iframe)}px`)}render(){const{configurable:e,headerVisible:t,headerDividerVisible:i}=this._state;this.setHeaderVisible(t),this.setHeaderDividerVisible(i),e&&this._modalLogoSrc&&this.updateHeaderLogo(this._modalLogoSrc),this.renderHeaderTemplate(),this.renderHeaderDescriptionTemplate(),this.renderFooterContent(),this.refreshHeaderIframeHeight()}dispatch(e){switch(this._analyticsContext){case n.CheckoutExtension:case n.Default:this._state=this._authenticationLevel===b.Phone?jt(e,this._state):function(e,t){const i=jt(e,t);switch(i.step){case w.Start:return Object.assign(Object.assign({},i),{headerTemplate:"verified_email_auth.auth_modal.login_title",descriptionTemplate:""});case w.SignUp:return Object.assign(Object.assign({},i),{headerTemplate:"verified_email_auth.auth_modal.signup_title",descriptionTemplate:"verified_email_auth.auth_modal.signup_description"});case w.PhoneVerification:return Object.assign(Object.assign({},i),{headerTemplate:"login_with_shop.auth_modal.login_sms_title",descriptionTemplate:"login_with_shop.auth_modal.login_sms_description"});case w.EmailVerification:return Object.assign(Object.assign({},i),{headerTemplate:"login_with_shop.auth_modal.login_email_title",descriptionTemplate:"login_with_shop.auth_modal.login_email_description"})}return i}(e,this._state);break;case n.ClassicCustomerAccounts:this._state="sign_up"===this._flowVersion?function(e,t){const i=jt(e,t);switch(i.step){case w.Start:case w.OneClick:return Object.assign(Object.assign({},i),{headerTemplate:"customer_accounts.sign_up_page.auth_modal.login_title",descriptionTemplate:"customer_accounts.sign_up_page.auth_modal.login_description"});case w.PhoneVerification:return Object.assign(Object.assign({},i),{headerTemplate:"customer_accounts.sign_up_page.auth_modal.login_title",descriptionTemplate:"customer_accounts.sign_up_page.auth_modal.login_sms_description"});case w.EmailVerification:return Object.assign(Object.assign({},i),{headerTemplate:"customer_accounts.sign_up_page.auth_modal.login_title",descriptionTemplate:"customer_accounts.sign_up_page.auth_modal.login_email_description"});case w.WebAuthnVerification:return Object.assign(Object.assign({},i),{headerTemplate:"customer_accounts.sign_up_page.auth_modal.login_title",descriptionTemplate:"login_with_shop.auth_modal.login_webauthn_description"})}return i}(e,this._state):jt(e,this._state);break;case n.CheckoutModal:this._state=function(e,t){const i=jt(e,t);switch(i.step){case w.PhoneVerification:return Object.assign(Object.assign({},i),{descriptionTemplate:"checkout_modal.auth_modal.login_sms_description"});case w.EmailVerification:return Object.assign(Object.assign({},i),{descriptionTemplate:"checkout_modal.auth_modal.login_email_description"})}return i}(e,this._state);break;case n.PaymentRequest:this._state=function(e,t){const i=jt(e,t);switch(i.step){case w.PopUpOpened:case w.OneClick:return Object.assign(Object.assign({},i),{headerTemplate:"payment_request.auth_modal.login_title",descriptionTemplate:"payment_request.auth_modal.login_description"});case w.PhoneVerification:return Object.assign(Object.assign({},i),{headerTemplate:"payment_request.auth_modal.login_sms_title",descriptionTemplate:"payment_request.auth_modal.login_sms_description"});case w.EmailVerification:return Object.assign(Object.assign({},i),{headerTemplate:"payment_request.auth_modal.login_email_title",descriptionTemplate:"payment_request.auth_modal.login_email_description"})}return i}(e,this._state);break;default:this._state=Pt}this._isCompact||this.render()}updateHeaderLogo(e){var t,i;if(!this._headerLogo){this._headerLogo=document.createElement("img");const e=null===(t=this._headerContentsContainer)||void 0===t?void 0:t.firstChild;e&&(null===(i=this._headerContentsContainer)||void 0===i||i.insertBefore(this._headerLogo,e))}this._headerLogo.src=e,this._headerLogo.style.maxHeight="64px",this._headerLogo.style.width="auto"}renderHeaderTemplate(){var e;const{configurable:t,headerTemplate:i,templateVariables:o}=this._state;let s="";if(t&&this._modalTitle)try{s=this._modalTitle.replace(/\${storeName}/gi,o.clientName)}catch(e){if(e instanceof Error&&e.message.includes("replaceAll is not a function"))return void p.notify(new Error("modalTitle is not a string. Expected string, received "+typeof this._modalTitle));throw e}else i&&(s=(null===(e=this._i18n)||void 0===e?void 0:e.translate(i,o))||"");"string"==typeof s&&(this._headerTitle.textContent=s)}renderHeaderDescriptionTemplate(){var e,t;const{configurable:i,descriptionTemplate:o,templateVariables:s}=this._state;let n="";i&&this._modalDescription?n=null===(e=this._modalDescription)||void 0===e?void 0:e.replace(/\${storeName}/gi,s.clientName):o&&(n=(null===(t=this._i18n)||void 0===t?void 0:t.translate(o,s))||""),"string"==typeof n&&(this._headerDescription.textContent=n)}renderFooterContent(){if(!this._i18n)return;const{step:e,templateVariables:t,sessionDetected:i}=this._state,{clientName:o,privacyPolicyUrl:s,termsOfServiceUrl:a}=t;let r="";switch(e){case w.PersonalizeConsent:case w.EmailVerification:case w.PhoneVerification:case w.WebAuthnVerification:case w.OneClick:{if(e===w.PersonalizeConsent&&!i)break;if(this._analyticsContext===n.PaymentRequest)break;const l=this._i18n.translate("legal.authorized_scopes.email_name",t);if(!s||!a){r=l;break}r=`${l} ${this._i18n.translate("legal.client",{clientName:o,privacyPolicy:`${this._i18n.translate("legal.privacy_policy")}`,termsOfService:`${this._i18n.translate("legal.terms")}`})}`;break}case w.SignUp:{const e=`${this._i18n.translate("legal.terms_of_service")}`,t=`${this._i18n.translate("legal.privacy_policy")}`;r=this._i18n.translate("legal.shop",{clientName:o,termsOfService:e,privacyPolicy:t});break}}this._footerContent.innerHTML=r,this.setFooterVisible(Boolean(r))}setHeaderVisible(e){var t;if(this._modalHeader.classList.toggle(P,!e),!this._headerIframe){this._headerIframe=this._sheetModalManager.shadowRoot.querySelector(`.${S}-container`);const e=null===(t=this._headerIframe.contentDocument)||void 0===t?void 0:t.querySelector("body");e.innerHTML=j,this._headerContentsContainer=document.createElement("div"),this._headerContentsContainer.classList.add($),this._headerTitle=document.createElement("h2"),this._headerTitle.classList.add(U),this._headerDescription=document.createElement("div"),this._headerDescription.classList.add(W),this._headerContentsContainer.appendChild(this._headerTitle),this._headerContentsContainer.appendChild(this._headerDescription),"pop_up"===this._flow&&(this._headerContentsContainer.style.display="flex",this._headerContentsContainer.style.flexDirection="column"),e.appendChild(this._headerContentsContainer),window.ResizeObserver?(this._headerResizeObserver=new ResizeObserver((()=>{this.refreshHeaderIframeHeight()})),this._headerResizeObserver.observe(this._headerContentsContainer)):this.refreshHeaderIframeHeight()}}refreshHeaderIframeHeight(){var e,t,i,o;const s=null===(t=null===(e=this._headerIframe)||void 0===e?void 0:e.contentDocument)||void 0===t?void 0:t.querySelector("body"),n=`${null===(i=this._headerContentsContainer)||void 0===i?void 0:i.getBoundingClientRect().height}px`;null==s||s.setAttribute("height",n),null===(o=this._headerIframe)||void 0===o||o.setAttribute("height",n)}setHeaderDividerVisible(e){this._modalHeader.classList.toggle(z,e)}setFooterVisible(e){this._footerElement.classList.toggle(P,!e)}setCloseButtonVisible(e){this._sheetModal.setCloseButtonVisibility(e)}setCustomizedModalContent({modalTitle:e,modalDescription:t,modalLogo:i}){e&&(this._modalTitle=Vt(e)),t&&(this._modalDescription=Vt(t)),i&&(this._modalLogoSrc=Vt(i))}getCustomizedModalContent(){return{modalTitle:this._modalTitle,modalDescription:this._modalDescription,modalLogo:this._modalLogoSrc}}setTranslations(e){this._i18n=e}isModalCustomized(){return Boolean(this._modalTitle||this._modalDescription||this._modalLogoSrc)}getModalAttributes(){var e,t;const i=null!==(t=null===(e=this._sheetModal)||void 0===e?void 0:e.getAttributeNames())&&void 0!==t?t:[];return N(this._isCompact,E,i),N(this._isHeaderless,F,i),i.map((e=>{var t;const i=null===(t=this._sheetModal)||void 0===t?void 0:t.getAttribute(e);return i?`${e}="${i}"`:e})).join(" ")}}const Wt=[n.Default,n.CheckoutExtension,n.CheckoutModal,n.ClassicCustomerAccounts,n.PaymentRequest];var zt,Nt,Ft,Dt,qt,Bt,Ht,Rt,Kt,Gt,Yt,Qt,Jt,Xt,Zt,ei,ti,ii,oi,si;const ni=[D.CaptchaChallenge];class ai extends B{static get observedAttributes(){return[I,H,R,K,G,Y,Q,J,X,Z,ee,O,te,ie,oe,se,ne,ae,re,le,he,ce,de,m,_,f,ue,pe,me,_e,fe,ge,we,ve,be,ye,ke,Ce,Se,Me,xe]}constructor(){super(),zt.add(this),Nt.set(this,Te()),Ft.set(this,""),Dt.set(this,"2"),qt.set(this,window.location.origin),Bt.set(this,new kt({elementName:"shop-login-default",analyticsTraceId:c(this,Nt,"f")})),Ht.set(this,void 0),Rt.set(this,void 0),Kt.set(this,void 0),Gt.set(this,void 0),Yt.set(this,void 0),Qt.set(this,null),this._disableSignUp=!1,this._autoOpen=!1,this._autoOpened=!1,this._analyticsContext=n.Default,this._avoidPayAltDomain=!1,this._avoidSdkSession=!1,this._flow=Ee.Default,this._flowVersion="unspecified",this._error="",this._hideButton=!1,this._anchorSelector="",this._isCompactLayout=!1,this._hidePayCopy=!1,this._email="",this._authorizeModalOpened=!1,this._keepModalOpen=!1,this._requireVerification=!1,this._shouldListenToResizeMessage=!0,Jt.set(this,(()=>{this._updateSrc(!0)})),Xt.set(this,(()=>{var e;this.dispatchCustomEvent("modalclosed"),null===(e=this._iframeMessenger)||void 0===e||e.postMessage({type:"sheetmodalclosed"}),Ae()})),Zt.set(this,(()=>{var e;this.dispatchCustomEvent("modalopened"),null===(e=this._iframeMessenger)||void 0===e||e.postMessage({type:"sheetmodalopened"})})),ei.set(this,(e=>{var t,i;const o=Le(this._analyticsContext);var s;return this._hidePayCopy=!o&&(s=this._analyticsContext,Wt.includes(s)),!(!e&&this._isCompactLayout===o)&&(this._isCompactLayout=o,null===(t=this._view)||void 0===t||t.setCompact(this._isCompactLayout),null===(i=this._view)||void 0===i||i.init(),!0)})),this._rootElement=this.attachShadow({mode:"open"}),this._analyticsContext=this.getAttribute(ee)||n.Default,this._view=new Ut(this._rootElement,{onOpen:c(this,Zt,"f"),onClose:c(this,Xt,"f")}),c(this,ei,"f").call(this,!0),this._debouncedUpdateUserInfo=Oe((({email:e,firstName:t,lastName:i})=>{var o;(null===(o=this._passwordManagerDetection)||void 0===o?void 0:o.isFilledWithPasswordManager())&&c(this,Bt,"f").trackPasswordManagerAutofillDetected(),this._updateUserInfo({email:e,firstName:t,lastName:i}),Fe(e)&&c(this,Bt,"f").trackEmailEnteredAction()}),Je),this._payLoadedResolve=()=>{},this._payLoaded=new Promise((e=>{this._payLoadedResolve=e}))}attributeChangedCallback(e,t,i){var o,s,a,r,l,h,u,p,g,w;const v=Boolean(null!==i);switch(e){case R:d(this,Dt,i,"f"),this._updateSrc();break;case H:d(this,Ft,i||"","f"),this._updateSrc();break;case te:this._responseType=i||"",this._updateSrc();break;case ie:this._responseMode=i||"",this._updateSrc();break;case oe:this._codeChallenge=i||"",this._updateSrc();break;case se:this._codeChallengeMethod=i||"",this._updateSrc();break;case ne:this._state=i||"",this._updateSrc();break;case ae:this._scope=i||"",this._updateSrc();break;case K:d(this,qt,i||window.location.origin,"f"),Ie(c(this,qt,"f"));break;case G:this._hideButton=v,null===(o=this._view)||void 0===o||o.setContinueButtonVisible(v),this._updateSrc();break;case re:this._avoidPayAltDomain=v,this._updateSrc();break;case le:this._avoidSdkSession=v,this._updateSrc();break;case he:this._flow=i||Ee.Default,null===(s=this._view)||void 0===s||s.setFlow(this._flow),this._updateSrc();break;case ce:this._flowVersion=i||"unspecified",null===(a=this._view)||void 0===a||a.setFlowVersion(this._flowVersion),this._updateMonorailTracker(),this._updateSrc();break;case Y:this._disableSignUp=v,this._updateSrc();break;case Q:this._autoOpen=v;break;case J:d(this,Ht,"pop_up"===i||"iframe"===i?i:"top_frame","f"),this._updateSrc();break;case X:d(this,Rt,i||void 0,"f"),this._updateSrc();break;case Z:d(this,Kt,i||void 0,"f"),null===(r=this._view)||void 0===r||r.setUxMode(c(this,Kt,"f")),this._updateSrc();break;case ee:this._analyticsContext=i||n.Default,null===(l=this._view)||void 0===l||l.setAnalyticsContext(this._analyticsContext),c(this,ei,"f").call(this),this._updateMonorailTracker(),this._updateSrc();break;case O:d(this,Nt,i||Te(),"f"),this._updateMonorailTracker(),this._updateSrc();break;case de:this._initEmail(i||"");break;case I:this._anchorSelector=i||"",null===(h=this._view)||void 0===h||h.setAnchorSelector(i||"");break;case m:null===(u=this._view)||void 0===u||u.setCustomizedModalContent({modalTitle:i||void 0}),this._updateSrc();break;case _:null===(p=this._view)||void 0===p||p.setCustomizedModalContent({modalDescription:i||void 0}),this._updateSrc();break;case f:null===(g=this._view)||void 0===g||g.setCustomizedModalContent({modalLogo:i||void 0}),this._updateSrc();break;case ue:this._apiKey=i||void 0,this._updateSrc();break;case pe:d(this,Gt,i||void 0,"f"),this._updateSrc();break;case me:d(this,Yt,i||void 0,"f"),this._updateSrc();break;case _e:null===(w=this._view)||void 0===w||w.setBrand(i||void 0);break;case fe:this._consentChallenge=v,this._updateSrc();break;case ge:this._checkoutRedirectUrl=i||void 0,this._updateSrc();break;case we:this._checkoutVersion=i||void 0,this._updateSrc(),this._updateMonorailTracker();break;case ve:this._checkoutToken=i||void 0,this._updateSrc(),this._updateMonorailTracker();break;case be:this._transactionParams=i||void 0,this._updateSrc();break;case ye:this._shopId=i||void 0,this._updateSrc(),this._updateMonorailTracker();break;case ke:this._shopPermanentDomain=i||void 0,this._updateMonorailTracker();break;case Ce:this._firstName=i||void 0;break;case Se:this._lastName=i||void 0;break;case Me:this._requireVerification=v,this._updateSrc();break;case xe:this._source=i||"unspecified"}}connectedCallback(){return h(this,void 0,void 0,(function*(){this.subscribeToHub(Ve.UserStatusIdentity,c(this,Jt,"f")),this._keepModalOpen=this.getBooleanAttribute(Pe),this._hideButton=this.getBooleanAttribute(G),this._apiKey=this.getAttribute(ue)||void 0,this._source=this.getAttribute(xe)||"unspecified";try{!function({modalTitle:e,modalDescription:t,modalLogo:i},o){if(Boolean(e||t||i)&&!o)throw new Error("An API key must be provided if the modal content is customized");if(e&&e.length>150)throw new Error(`${m} cannot exceed 150 characters.`);if(t&&t.length>300)throw new Error(`${_} cannot exceed 300 characters.`);if(i)try{new URL(i)}catch(e){throw new Error(`${f} must be a valid URL`)}}(this._view.getCustomizedModalContent(),this._apiKey),yield c(this,zt,"m",ti).call(this),yield this._initElements(),Ie(c(this,qt,"f")),c(this,Bt,"f").trackFeatureInitialization({apiKey:this._apiKey,source:this._source})}catch(e){e instanceof Error&&(je(`Invalid config. ${e.message}`),this._handleError("invalid_config",D.ApiUnavailable))}}))}_initElements(){return h(this,void 0,void 0,(function*(){var e,t;if(!this._view)return;this._view.setModalAnalyticsTraceId(c(this,Nt,"f")),this._view.setMonorailTracker(c(this,Bt,"f")),this._view.setAnchorSelector(this._anchorSelector),this._view.setContinueButtonVisible(!this._hideButton),this._iframe=this._view.getIframe(),this._updateSrc();const i=(null===(e=this.ownerDocument)||void 0===e?void 0:e.defaultView)||void 0;this._iframeListener=new $e(new Ue(this._iframe),[r,We,c(this,qt,"f")],c(this,zt,"m",si).bind(this),i),this._iframeMessenger=new ze(this._iframe);const{userFound:o}=yield this._iframeListener.waitForMessage("loaded");this._payLoadedResolve({userFound:o}),this.dispatchCustomEvent("iframeloaded"),c(this,Bt,"f").trackShopPayModalStateChange({currentState:Ne.Loaded,reason:"event_loaded"}),c(this,zt,"m",oi).call(this),o&&this._autoOpen&&!this._autoOpened&&(null===(t=this._updateEmailAbortController)||void 0===t||t.abort(),this._autoOpened=!0,yield this._view.openAuthorizeModal("event_loaded_with_auto_open"))}))}_initEmail(e){this._email=e,Fe(this._email)?this._debouncedUpdateUserInfo({email:this._email,firstName:this._firstName,lastName:this._lastName}):this._debouncedUpdateUserInfo({email:""})}disconnectedCallback(){var e,t;this.unsubscribeAllFromHub(),null===(e=this._iframeListener)||void 0===e||e.destroy(),null===(t=this._view)||void 0===t||t.destroy(),this.stopListeningToInput()}setShouldListenToResizeMessage(e){this._shouldListenToResizeMessage=e}requestShow(e){return h(this,void 0,void 0,(function*(){var t;yield this._payLoaded,this._authorizeModalOpened?p.notify(new Error("requestShow called when the modal is not closed")):(e&&this._updateUserInfo({email:e,firstName:this._firstName,lastName:this._lastName}),yield this._payLoaded,yield null===(t=this._view)||void 0===t?void 0:t.openAuthorizeModal("user_button_clicked"))}))}setPasswordManagerDetection(e){this._passwordManagerDetection=e}listenToInput(e){this.stopListeningToInput();const t=Oe((e=>{Fe(e)?(this._updateUserInfo({email:e}),c(this,Bt,"f").trackEmailEnteredAction()):this._updateUserInfo({email:""})}),Je);t(e.value),this._inputListener=new De(e,t)}getIframe(){var e;return null===(e=this._view)||void 0===e?void 0:e.getIframe()}ensureIframeIsLoaded(){return this._payLoaded.then((()=>{}))}stopListeningToInput(){var e;null===(e=this._inputListener)||void 0===e||e.destroy()}_updateUserInfo(e){return h(this,arguments,void 0,(function*({email:e,firstName:t="",lastName:i=""}){var o,s;if(!this._authorizeModalOpened){this._updateEmailAbortController&&!(null===(o=this._updateEmailAbortController)||void 0===o?void 0:o.signal.aborted)&&this._updateEmailAbortController.abort(),this._updateEmailAbortController=new AbortController;try{const{userFound:o}=yield this._payLoaded;if(o&&this._autoOpen&&!this._autoOpened)return;this._iframeMessenger.postMessage({type:"namesubmitted",firstName:t,lastName:i}),this._iframeMessenger.postMessage({type:"emailsubmitted",email:e,hideChange:e.length>0});const n=this._iframeListener.waitForMessage("shop_user_matched",this._updateEmailAbortController.signal),a=new Promise(((e,t)=>{const i=()=>h(this,void 0,void 0,(function*(){try{const{code:t}=yield this._iframeListener.waitForMessage("error",this._updateEmailAbortController.signal);t===D.CaptchaChallenge?e(void 0):i()}catch(e){t(e)}}));i()}));yield Promise.race([n,a]),yield null===(s=this._view)||void 0===s?void 0:s.openAuthorizeModal("event_shop_user_matched"),this._updateEmailAbortController.abort()}catch(e){if(e instanceof qe)return;e instanceof Error&&p.notify(new Error(`Error updating user info: ${e.name} - ${e.message}`))}}}))}_updateSrc(e){var t,i,o;const s=null===(t=this._view)||void 0===t?void 0:t.getIframe();if(!s&&"redirect"!==(null===(i=this._view)||void 0===i?void 0:i.getUxMode()))return;const n=this._buildAuthorizeUrl();null===(o=this._view)||void 0===o||o.setAuthorizeUrl(n),s&&n&&(this._updateListeners(s),this._iframeSrcTimeout&&clearTimeout(this._iframeSrcTimeout),this._iframeSrcTimeout=setTimeout((()=>{c(this,zt,"m",ii).call(this),Be(s,n,e),p.leaveBreadcrumb("Iframe url updated",{authorizeUrl:n},"state")}),0))}_buildAuthorizeUrl(){var e;const t={clientId:c(this,Ft,"f"),responseType:this._responseType,responseMode:this._responseMode,redirectType:c(this,Ht,"f"),redirectUri:c(this,Rt,"f"),codeChallenge:this._codeChallenge,codeChallengeMethod:this._codeChallengeMethod,state:this._state,scope:this._scope},i=null===(e=this._view)||void 0===e?void 0:e.isModalCustomized();return xt(Object.assign(Object.assign({version:c(this,Dt,"f"),analyticsTraceId:c(this,Nt,"f"),analyticsContext:this._analyticsContext,isCompactLayout:this._isCompactLayout,flow:this._flow,flowVersion:this._flowVersion,signUpEnabled:!this._disableSignUp,oauthParams:t,avoidPayAltDomain:this._avoidPayAltDomain,avoidSdkSession:this._avoidSdkSession,hideCopy:this._hidePayCopy},i&&{modalCustomized:i}),{apiKey:this._apiKey,popupWindowParams:{popUpName:c(this,Gt,"f"),popUpFeatures:c(this,Yt,"f")},consentChallenge:this._consentChallenge,checkoutRedirectUrl:this._checkoutRedirectUrl,checkoutVersion:this._checkoutVersion,checkoutToken:this._checkoutToken,transactionParams:this._transactionParams,shopId:this._shopId,requireVerification:this._requireVerification,uxMode:c(this,Kt,"f"),error:this._error}))}_updateListeners(e){this._iframeListener&&(this._iframeListener.eventSource=new Ue(e)),this._iframeMessenger&&(this._iframeMessenger.eventDestination=e)}_updateMonorailTracker(){var e;d(this,Bt,new kt({elementName:"shop-login-default",analyticsTraceId:c(this,Nt,"f"),analyticsContext:this._analyticsContext,flowVersion:this._flowVersion,shopId:He(this._shopId),shopPermanentDomain:this._shopPermanentDomain,checkoutVersion:this._checkoutVersion,checkoutToken:this._checkoutToken}),"f"),null===(e=this._view)||void 0===e||e.setMonorailTracker(c(this,Bt,"f"))}_handleCompleted(e,t,i,o,s,n,a,r){return h(this,void 0,void 0,(function*(){var l,h;e&&s&&(yield Re(c(this,qt,"f"),p.notify),this.publishToHub(Ve.UserSessionCreate,{email:a||t,initial:(null==a?void 0:a[0])||(null==t?void 0:t[0])||"",avatar:r})),this._keepModalOpen||(yield null===(l=this._view)||void 0===l?void 0:l.closeAuthorizeModal({modalStateChangeReason:"event_completed"})),null===(h=this._iframeListener)||void 0===h||h.destroy(),this.stopListeningToInput(),this.dispatchCustomEvent("completed",{loggedIn:e,email:t,customerAccessToken:i,customerAccessTokenExpiresAt:o,shopPayInstallmentsOnboarded:n}),this._maybeRedirect()}))}_handleCustomFlowSideEffect(e){return h(this,void 0,void 0,(function*(){if(e.flow===Ee.Prequal)this.dispatchCustomEvent("prequal_flow_side_effect",{shopPayInstallmentsOnboarded:e.shopPayInstallmentsOnboarded})}))}_maybeRedirect(){if("pop_up"!==c(this,Ht,"f")&&c(this,Rt,"f"))try{let e=c(this,Rt,"f");if(c(this,Nt,"f")){const t={analytics_trace_id:c(this,Nt,"f")},i=new URLSearchParams(t);e=e.concat(`?${i.toString()}`)}else p.notify(new Error("Missing analytics trace ID when redirecting to account page"));window.location.assign(e)}catch(e){e instanceof Error&&p.notify(e)}}_handleError(e,t){this.dispatchCustomEvent("error",{message:e,code:t}),t===D.RetriableServerError&&(this._error=t,this._updateSrc(!0)),ni.includes(t)?Ke(Ge.HandleSilentError,1,{component:"shop-login-default",errorCode:t}):p.notify(new Error(`Authorize Error: ${e} (${t}).`)),c(this,zt,"m",oi).call(this)}_onPopUpOpened(e){var t;e.didOpen&&(null===(t=this._view)||void 0===t||t.dispatch({type:v.PopUpOpened,payload:e})),this.dispatchCustomEvent("popuploading",e)}_onLoaded(e){var t,i,o;null===(t=this._view)||void 0===t||t.setAuthenticationLevel((null==e?void 0:e.authenticationLevelRequired)||b.Phone),null===(i=this._view)||void 0===i||i.dispatch({type:v.Init,payload:e}),null===(o=this._view)||void 0===o||o.onContentLoaded()}_onUserMatched({hasName:e=!1,userCookieExists:t=!1,personalizeConsentChallenge:i=!1}){var o;null===(o=this._view)||void 0===o||o.dispatch({type:v.UserMatched,payload:{hasName:e,userCookieExists:t,personalizeConsentChallenge:i}}),Ye(),this.dispatchCustomEvent("shopusermatched")}_onUserNotMatched({apiError:e}){var t;null===(t=this._view)||void 0===t||t.dispatch({type:v.UserNotMatched}),this.dispatchCustomEvent("shopusernotmatched",{apiError:e})}_onEmailChangeRequested(){var e;null===(e=this._view)||void 0===e||e.dispatch({type:v.Restart}),this.dispatchCustomEvent("restarted")}_onVerificationStepChanged(e){var t;null===(t=this._view)||void 0===t||t.dispatch({type:v.VerificationStepChanged,payload:e})}}function ri(){q("shop-login-default",ai)}var li,hi;Nt=new WeakMap,Ft=new WeakMap,Dt=new WeakMap,qt=new WeakMap,Bt=new WeakMap,Ht=new WeakMap,Rt=new WeakMap,Kt=new WeakMap,Gt=new WeakMap,Yt=new WeakMap,Qt=new WeakMap,Jt=new WeakMap,Xt=new WeakMap,Zt=new WeakMap,ei=new WeakMap,zt=new WeakSet,ti=function(){return h(this,void 0,void 0,(function*(){var e;try{const t="en",i={follow_on_shop:{follow:"Follow on {shop}",following:"Following on {shop}",auth_modal:{title:"Follow on Shop",description:"Stay in the know—never miss a sale, restock, or order update."},following_modal:{title:"Visit {store} on Shop",subtitle:"Everything you need to shop, track, and pay—all in one place.",qr_header:"Scan to visit {store} on the Shop app",qr_alt_text:"Shop app QR code",continue:"Continue"},completed:{title:"You're following {store}",subtitle:"We've sent you an email with a link to download the Shop app."},personalization_consent:{title:"To follow on Shop, sync your shopping activity"}},login_with_shop:{login:"Sign in with {shop}",auth_modal:{login_title:"Sign in with Shop",login_title_with_store:"Sign in to {store} with Shop",login_description:"The easiest and most secure way to sign in to {store}—no password needed.",signup_title:"Create an account",signup_description:"Enter your phone number to create a Shop account.",login_sms_title:"Confirm it's you",login_sms_description:"Enter the code sent to {phoneNumber}",login_email_title:"Confirm it’s you",login_email_description:"Enter the code sent to your email, {email}",login_webauthn_title:"Confirm it’s you",login_webauthn_description:"Sign in with a passkey to securely use your saved information.",login_webauthn_footer:"By continuing, your name and email address will be shared with {store}."}},verified_email_auth:{auth_modal:{login_title:"Log in or sign up",signup_title:"Continue with Shop",signup_description:"Create a Shop account to sign in to {clientName}–no passwords needed"}},legal:{terms_of_service:"terms of service",privacy_policy:"privacy policy",terms:"terms",client:"See {clientName}’s {termsOfService} and {privacyPolicy}.",shop:"By continuing, you agree to Shop’s {termsOfService} and acknowledge the {privacyPolicy}.",authorized_scopes:{email_name:"By continuing, your name and email address will be shared with {store}."}},checkout_modal:{auth_modal:{login_sms_description:"Enter the code sent to {phoneNumber} to securely use your saved information.",login_email_description:"Enter the code sent to your email, {email} to securely use your saved information."}},customer_accounts:{remember_me:"Save my info securely with Shop to sign in faster everywhere",sign_up_page:{auth_modal:{login_title:"Continue with Shop",login_description:"Use your Shop account to sign in everywhere—no password needed.",login_sms_description:"Use your Shop account to sign in everywhere—no password needed.\r\n\r\nConfirm it's you, enter the code sent to {phoneNumber}",login_email_description:"Use your Shop account to sign in everywhere—no password needed.\r\n\r\nConfirm it's you, enter the code sent to your email, {email}",login_webauthn_title:"Continue with Shop",login_webauthn_description:"Sign in with a passkey to securely use your saved information."}}},payment_request:{auth_modal:{login_title:"Check out with Shop Pay",login_description:"Use your saved information to check out securely at {store}.",login_sms_title:"Confirm it's you",login_sms_description:"Enter the code sent to {phoneNumber} to securely use your saved information.",login_email_title:"Confirm it’s you",login_email_description:"Enter the code sent to your email, {email} to securely use your saved information."}}};d(this,Qt,new u({[t]:i}),"f"),null===(e=this._view)||void 0===e||e.setTranslations(c(this,Qt,"f"))}catch(e){e instanceof Error&&p.notify(e)}return null}))},ii=function(){c(this,zt,"m",oi).call(this),this._iframeLoadTimeout=setTimeout((()=>{const e=Xe.temporarilyUnavailable;this.dispatchCustomEvent("error",{message:e.message,code:e.code}),c(this,zt,"m",oi).call(this)}),Qe)},oi=function(){this._iframeLoadTimeout&&(clearTimeout(this._iframeLoadTimeout),this._iframeLoadTimeout=void 0)},si=function(e){var t,i;switch(e.type){case"loaded":this._onLoaded(e);break;case"resize_iframe":if(!this._shouldListenToResizeMessage)return;null===(t=this._view)||void 0===t||t.resizeIframe(e.height,V(e.width,this._view.getIframe()));break;case"completed":this._handleCompleted(e.loggedIn,e.email,e.customerAccessToken,e.customerAccessTokenExpiresAt,e.shouldFinalizeLogin,e.shopPayInstallmentsOnboarded,e.givenName,e.avatar);break;case"error":this._handleError(e.message,e.code);break;case"close_requested":null===(i=this._view)||void 0===i||i.closeAuthorizeModal({modalStateChangeReason:"event_close_requested"});break;case"shop_user_matched":this._onUserMatched(e);break;case"pop_up_opened":this._onPopUpOpened(e);break;case"shop_user_not_matched":this._onUserNotMatched(e);break;case"email_change_requested":this._onEmailChangeRequested();break;case"verification_step_changed":this._onVerificationStepChanged(e);break;case"custom_flow_side_effect":this._handleCustomFlowSideEffect(e)}};const ci={[Ee.Follow]:"shop-follow-button",[Ee.Default]:"shop-login-default",[Ee.Prequal]:"shop-login-default",[Ee.PopUp]:"shop-login-default",[Ee.Custom]:"shop-login-default"},di={[G]:!1,[Y]:!1,[Q]:!1,[ee]:"",[re]:!1,[le]:!1,[ce]:"unspecified",[de]:"",[tt]:!1,[Pe]:!1,[fe]:!1,[Me]:!1,[xe]:"unspcified"};class ui extends Ze{constructor(){super(...arguments),li.set(this,void 0),hi.set(this,void 0)}static get observedAttributes(){return[H,R,ce,K,G,Y,Q,et,J,X,ee,X,Z,te,ie,oe,se,ne,ae,de,I,tt,m,_,f,ue,pe,me,_e,fe,O,ge,we,ve,be,ye,ke,Ce,Se,Me,re,le,Pe,xe]}get clientId(){return this._getAttributeValueWithDefault(H)}set clientId(e){this.updateAttribute(H,e)}set redirectUri(e){this.updateAttribute(X,e)}get version(){return this._getAttributeValueWithDefault(R)}set version(e){this.updateAttribute(R,e)}get email(){return this._getAttributeValueWithDefault(de)}set email(e){this.updateAttribute(de,e)}set firstName(e){this.updateAttribute(Ce,e)}set lastName(e){this.updateAttribute(Se,e)}set popUpName(e){this.updateAttribute(pe,e)}set popUpFeatures(e){this.updateAttribute(me,e)}connectedCallback(){var e;d(this,li,it(this.getAttribute(ot),Ee,Ee.Default),"f"),d(this,hi,this._createActionButton({actionType:c(this,li,"f"),attributes:this._getAttributeValues()}),"f"),this.shadowRoot||this.attachShadow({mode:"open"}),c(this,hi,"f")&&(this.shadowRoot.innerHTML="",null===(e=this.shadowRoot)||void 0===e||e.appendChild(c(this,hi,"f")))}disconnectedCallback(){}attributeChangedCallback(e,t,i){var o,s;const n=i||this._getAttributeValueWithDefault(e);"boolean"==typeof n?this.updateAttribute(e,n?"":void 0):this.updateAttribute(e,n||void 0),null===i?null===(o=c(this,hi,"f"))||void 0===o||o.removeAttribute(e):null===(s=c(this,hi,"f"))||void 0===s||s.setAttribute(e,i)}requestShow(e){c(this,hi,"f")&&"requestShow"in c(this,hi,"f")&&c(this,hi,"f").requestShow(e)}listenToInput(e){c(this,hi,"f")&&"listenToInput"in c(this,hi,"f")&&c(this,hi,"f").listenToInput(e)}stopListeningToInput(){c(this,hi,"f")&&"stopListeningToInput"in c(this,hi,"f")&&c(this,hi,"f").stopListeningToInput()}setPasswordManagerDetection(e){c(this,hi,"f")&&"setPasswordManagerDetection"in c(this,hi,"f")&&c(this,hi,"f").setPasswordManagerDetection(e)}dispatchCustomEvent(e,t){super.dispatchCustomEvent(e,t)}_createActionButton({actionType:e,attributes:t}){const i=ci[e];if(!i)return;const o=document.createElement(i);return o?(Object.entries(t).forEach((([e,t])=>{t&&o.setAttribute(e,String(t))})),o):void 0}_getAttributeValues(){return ui.observedAttributes.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:this._getAttributeValueWithDefault(t)})),Object.assign(Object.assign({},di),{[he]:this._getAttributeValueWithDefault(ot)}))}_getAttributeValueWithDefault(e){switch(e){case ot:case he:return it(this.getAttribute(ot),Ee,Ee.Default);case G:case Y:case Q:case re:case le:case tt:case Pe:case fe:case Me:case et:return this.getBooleanAttribute(e);case ee:case de:return this.getAttribute(e)||"";case ce:return this.getAttribute(e)||"unspecified";case O:return this.getAttribute(e)||Te();default:return this.getAttribute(e)||void 0}}}function pi(){q("shop-login-button",ui)}li=new WeakMap,hi=new WeakMap;class mi extends HTMLElement{constructor(){super();const e=document.createElement("template"),t=this.getAttribute("size"),i=this.getAttribute("background-color")||"#FFF";e.innerHTML=function(e=36,t){const[i,o,s]=st(t),n=`rgb(${i}, ${o}, ${s})`,a=1.15,r=e,l=Math.round(r/a);return`\n \n \n `}(t?Number.parseInt(t,10):void 0,i),this.attachShadow({mode:"open"}).appendChild(e.content.cloneNode(!0))}}var _i,fi,gi,wi,vi,bi,yi,ki,Ci,Si,Mi,xi,Ti,Ei,Ai;const Li="shop-modal-content";class Oi extends HTMLElement{constructor(){super(),_i.add(this),fi.set(this,void 0),gi.set(this,void 0),wi.set(this,void 0),vi.set(this,void 0),bi.set(this,void 0),yi.set(this,void 0),ki.set(this,void 0),Ci.set(this,void 0),Si.set(this,void 0),Mi.set(this,void 0),xi.set(this,{});const e=document.createElement("template");e.innerHTML=`\n \n
\n \n \n
\n
\n
\n \n \n
\n
\n \n
\n \n
\n `,d(this,fi,this.attachShadow({mode:"open"}),"f"),c(this,fi,"f").appendChild(e.content.cloneNode(!0)),d(this,gi,c(this,fi,"f").querySelector(`.${Li}`),"f"),d(this,wi,c(this,fi,"f").querySelector(`.${Li}-title`),"f"),d(this,vi,c(this,fi,"f").querySelector(`.${Li}-description`),"f"),d(this,bi,c(this,fi,"f").querySelector(`.${Li}-content`),"f"),d(this,yi,c(this,fi,"f").querySelector(`.${Li}-processing`),"f"),d(this,ki,c(this,fi,"f").querySelector(`.${Li}-processing-user`),"f"),d(this,Si,c(this,fi,"f").querySelector(`.${Li}-children`),"f"),d(this,Mi,c(this,fi,"f").querySelector(`.${Li}-disclaimer`),"f")}hideDivider(){c(this,gi,"f").classList.add("hide-divider")}showDivider(){c(this,gi,"f").classList.remove("hide-divider")}update(e){d(this,xi,Object.assign(Object.assign({},c(this,xi,"f")),e),"f"),c(this,_i,"m",Ti).call(this),c(this,_i,"m",Ei).call(this),c(this,_i,"m",Ai).call(this)}}function Ii(e,t=!1){const i=document.createElement("shop-modal-content");return t&&i.hideDivider(),i.update(e),i}fi=new WeakMap,gi=new WeakMap,wi=new WeakMap,vi=new WeakMap,bi=new WeakMap,yi=new WeakMap,ki=new WeakMap,Ci=new WeakMap,Si=new WeakMap,Mi=new WeakMap,xi=new WeakMap,_i=new WeakSet,Ti=function(){const{title:e,description:t,authorizeState:i}=c(this,xi,"f"),o=e||t;c(this,gi,"f").classList.toggle("hidden",!o),c(this,wi,"f").classList.toggle("hidden",!e),c(this,vi,"f").classList.toggle("hidden",!t),c(this,wi,"f").textContent=e||"",c(this,vi,"f").textContent=t||"",i&&(c(this,gi,"f").classList.toggle("hide-divider",i===at.Start),c(this,gi,"f").classList.toggle(`${Li}--small`,i===at.Start))},Ei=function(){var e;const{authorizeState:t,status:i,email:o}=c(this,xi,"f"),s=Boolean(t||i),n=Boolean(i&&o),a=Boolean(s&&!n);if(c(this,bi,"f").classList.toggle("hidden",!s),c(this,yi,"f").classList.toggle("hidden",!n),c(this,Si,"f").classList.toggle("hidden",!a),!c(this,Ci,"f")&&n){const i=t===at.OneClick?rt.Branded:rt.Regular;d(this,Ci,lt(i),"f"),c(this,yi,"f").appendChild(c(this,Ci,"f")),null===(e=c(this,Ci,"f"))||void 0===e||e.setStatus({status:"loading",message:""})}c(this,ki,"f").textContent=o||""},Ai=function(){const{disclaimer:e}=c(this,xi,"f"),t=Boolean(e);c(this,Mi,"f").classList.toggle("hidden",!t),c(this,Mi,"f").innerHTML=e||""},customElements.get("shop-modal-content")||customElements.define("shop-modal-content",Oi);const Vi="following";class Pi extends HTMLElement{constructor(){super(),this._rootElement=null,this._button=null,this._wrapper=null,this._heartIcon=null,this._followSpan=null,this._followingSpan=null,this._i18n=null,this._followTextWidth=0,this._followingTextWidth=0,customElements.get("shop-logo")||customElements.define("shop-logo",l)}connectedCallback(){return h(this,void 0,void 0,(function*(){yield this._initTranslations(),this._initElements()}))}setFollowing({following:e=!0,skipAnimation:t=!1}){var i,o,s,n,a;null===(i=this._button)||void 0===i||i.classList.toggle("button--animating",!t),null===(o=this._button)||void 0===o||o.classList.toggle("button--following",e),null!==this._followSpan&&null!==this._followingSpan&&(this._followSpan.ariaHidden=e?"true":"false",this._followingSpan.ariaHidden=e?"false":"true"),this.style.setProperty("--button-width",`${e?this._followingTextWidth:this._followTextWidth}px`),window.matchMedia("(prefers-reduced-motion: reduce)").matches||t?null===(s=this._heartIcon)||void 0===s||s.setFilled(e):null===(a=null===(n=this._button)||void 0===n?void 0:n.querySelector(".follow-text"))||void 0===a||a.addEventListener("transitionend",(()=>{var t;null===(t=this._heartIcon)||void 0===t||t.setFilled(e)}))}setFocused(){var e;null===(e=this._button)||void 0===e||e.focus()}_initTranslations(){return h(this,void 0,void 0,(function*(){try{const e="en",t={follow_on_shop:{follow:"Follow on {shop}",following:"Following on {shop}",auth_modal:{title:"Follow on Shop",description:"Stay in the know—never miss a sale, restock, or order update."},following_modal:{title:"Visit {store} on Shop",subtitle:"Everything you need to shop, track, and pay—all in one place.",qr_header:"Scan to visit {store} on the Shop app",qr_alt_text:"Shop app QR code",continue:"Continue"},completed:{title:"You're following {store}",subtitle:"We've sent you an email with a link to download the Shop app."},personalization_consent:{title:"To follow on Shop, sync your shopping activity"}},login_with_shop:{login:"Sign in with {shop}",auth_modal:{login_title:"Sign in with Shop",login_title_with_store:"Sign in to {store} with Shop",login_description:"The easiest and most secure way to sign in to {store}—no password needed.",signup_title:"Create an account",signup_description:"Enter your phone number to create a Shop account.",login_sms_title:"Confirm it's you",login_sms_description:"Enter the code sent to {phoneNumber}",login_email_title:"Confirm it’s you",login_email_description:"Enter the code sent to your email, {email}",login_webauthn_title:"Confirm it’s you",login_webauthn_description:"Sign in with a passkey to securely use your saved information.",login_webauthn_footer:"By continuing, your name and email address will be shared with {store}."}},verified_email_auth:{auth_modal:{login_title:"Log in or sign up",signup_title:"Continue with Shop",signup_description:"Create a Shop account to sign in to {clientName}–no passwords needed"}},legal:{terms_of_service:"terms of service",privacy_policy:"privacy policy",terms:"terms",client:"See {clientName}’s {termsOfService} and {privacyPolicy}.",shop:"By continuing, you agree to Shop’s {termsOfService} and acknowledge the {privacyPolicy}.",authorized_scopes:{email_name:"By continuing, your name and email address will be shared with {store}."}},checkout_modal:{auth_modal:{login_sms_description:"Enter the code sent to {phoneNumber} to securely use your saved information.",login_email_description:"Enter the code sent to your email, {email} to securely use your saved information."}},customer_accounts:{remember_me:"Save my info securely with Shop to sign in faster everywhere",sign_up_page:{auth_modal:{login_title:"Continue with Shop",login_description:"Use your Shop account to sign in everywhere—no password needed.",login_sms_description:"Use your Shop account to sign in everywhere—no password needed.\r\n\r\nConfirm it's you, enter the code sent to {phoneNumber}",login_email_description:"Use your Shop account to sign in everywhere—no password needed.\r\n\r\nConfirm it's you, enter the code sent to your email, {email}",login_webauthn_title:"Continue with Shop",login_webauthn_description:"Sign in with a passkey to securely use your saved information."}}},payment_request:{auth_modal:{login_title:"Check out with Shop Pay",login_description:"Use your saved information to check out securely at {store}.",login_sms_title:"Confirm it's you",login_sms_description:"Enter the code sent to {phoneNumber} to securely use your saved information.",login_email_title:"Confirm it’s you",login_email_description:"Enter the code sent to your email, {email} to securely use your saved information."}}};this._i18n=new u({[e]:t})}catch(e){e instanceof Error&&p.notify(e)}return null}))}_initElements(){var e,t,i,o;const s=document.createElement("template");if(s.innerHTML=`\n \n \n `,this._rootElement=this.attachShadow({mode:"open"}),this._rootElement.appendChild(s.content.cloneNode(!0)),this._i18n){const e=this._i18n.translate("follow_on_shop.follow",{shop:ji("white")}),t=this._i18n.translate("follow_on_shop.following",{shop:ji("black")});this._rootElement.querySelector('slot[name="follow-text"]').innerHTML=e,this._rootElement.querySelector('slot[name="following-text"]').innerHTML=t}this._button=this._rootElement.querySelector(".button"),this._wrapper=this._button.querySelector(".follow-icon-wrapper"),this._followSpan=null===(e=this._rootElement)||void 0===e?void 0:e.querySelector("span.follow-text"),this._followingSpan=null===(t=this._rootElement)||void 0===t?void 0:t.querySelector("span.following-text"),this._heartIcon=ht(),this._wrapper.prepend(this._heartIcon),this._followTextWidth=(null===(i=this._rootElement.querySelector(".follow-text"))||void 0===i?void 0:i.scrollWidth)||0,this._followingTextWidth=(null===(o=this._rootElement.querySelector(".following-text"))||void 0===o?void 0:o.scrollWidth)||0,this.style.setProperty("--reserved-width",`${Math.max(this._followTextWidth,this._followingTextWidth)}px`),this.setFollowing({following:this.hasAttribute(Vi),skipAnimation:!0}),this._setButtonStyle()}_setButtonStyle(){var e,t;const i=ct(this),o=dt(i,"#ffffff")>dt(i,"#000000"),s=dt(i,"#5433EB")<=3.06;if(null===(e=this._button)||void 0===e||e.classList.toggle("button--dark",o),null===(t=this._button)||void 0===t||t.classList.toggle("button--bordered",s),o&&this._i18n){const e=this._i18n.translate("follow_on_shop.following",{shop:ji("white")});this._rootElement.querySelector('slot[name="following-text"]').innerHTML=e}}}function ji(e){return``}var $i,Ui,Wi,zi,Ni,Fi,Di,qi,Bi,Hi;customElements.get("follow-on-shop-button")||customElements.define("follow-on-shop-button",Pi);const Ri="store-logo";class Ki extends HTMLElement{constructor(){super(),$i.add(this),Ui.set(this,void 0),Wi.set(this,void 0),zi.set(this,void 0),Ni.set(this,void 0),Fi.set(this,void 0),Di.set(this,void 0),qi.set(this,""),Bi.set(this,"");const e=document.createElement("template");e.innerHTML=`\n \n
\n
\n \n \n
\n \n
\n `,d(this,Ui,this.attachShadow({mode:"open"}),"f"),c(this,Ui,"f").appendChild(e.content.cloneNode(!0)),d(this,Wi,c(this,Ui,"f").querySelector(`.${Ri}`),"f"),d(this,zi,c(this,Ui,"f").querySelector(`.${Ri}-logo-wrapper`),"f"),d(this,Ni,c(this,zi,"f").querySelector("img"),"f"),d(this,Fi,c(this,zi,"f").querySelector("span"),"f"),d(this,Di,ht(),"f"),c(this,Ui,"f").querySelector(`.${Ri}-icon-wrapper`).append(c(this,Di,"f"))}update({name:e,logoSrc:t}){d(this,qi,e||c(this,qi,"f"),"f"),d(this,Bi,t||c(this,Bi,"f"),"f"),c(this,$i,"m",Hi).call(this)}connectedCallback(){c(this,Ni,"f").addEventListener("error",(()=>{d(this,Bi,"","f"),c(this,$i,"m",Hi).call(this)}))}setFavorited(){return c(this,Wi,"f").classList.add(`${Ri}--favorited`),window.matchMedia("(prefers-reduced-motion: reduce)").matches?(c(this,Di,"f").setFilled(),Promise.resolve()):new Promise((e=>{c(this,Di,"f").addEventListener("animationstart",(()=>{c(this,Di,"f").setFilled()})),c(this,Di,"f").addEventListener("animationend",(()=>{setTimeout(e,1e3)}))}))}}var Gi,Yi,Qi,Ji,Xi,Zi,eo,to,io,oo,so,no,ao,ro,lo,ho,co,uo,po,mo,_o,fo,go,wo,vo,bo,yo,ko,Co,So,Mo,xo,To,Eo,Ao,Lo,Oo,Io,Vo,Po,jo,$o,Uo,Wo,zo,No,Fo,Do,qo,Bo,Ho;Ui=new WeakMap,Wi=new WeakMap,zi=new WeakMap,Ni=new WeakMap,Fi=new WeakMap,Di=new WeakMap,qi=new WeakMap,Bi=new WeakMap,$i=new WeakSet,Hi=function(){const e=c(this,qi,"f"),t=c(this,Ni,"f").src;c(this,Fi,"f").textContent=e.charAt(0),c(this,Fi,"f").ariaLabel=e,c(this,Bi,"f")&&c(this,Bi,"f")!==t?(c(this,Ni,"f").src=c(this,Bi,"f"),c(this,Ni,"f").alt=e,c(this,zi,"f").classList.remove(`${Ri}-logo-wrapper--text`),c(this,zi,"f").classList.add(`${Ri}-logo-wrapper--image`)):c(this,Bi,"f")||(c(this,zi,"f").classList.remove(`${Ri}-logo-wrapper--image`),c(this,zi,"f").classList.add(`${Ri}-logo-wrapper--text`))},customElements.get(Ri)||customElements.define(Ri,Ki),function(e){e.Closed="closed",e.Mounting="mounting",e.Open="open"}(Ho||(Ho={}));class Ro extends B{static get observedAttributes(){return[H,R,K,tt]}constructor(){super(),Gi.add(this),Yi.set(this,void 0),Qi.set(this,Te()),Ji.set(this,""),Xi.set(this,"2"),Zi.set(this,window.location.origin),eo.set(this,!1),to.set(this,new yt({elementName:"shop-follow-button",analyticsTraceId:c(this,Qi,"f")})),io.set(this,void 0),oo.set(this,void 0),so.set(this,!1),no.set(this,null),ao.set(this,void 0),ro.set(this,void 0),lo.set(this,void 0),ho.set(this,void 0),co.set(this,void 0),uo.set(this,void 0),po.set(this,void 0),mo.set(this,void 0),_o.set(this,void 0),fo.set(this,Ho.Closed),go.set(this,void 0),wo.set(this,void 0),vo.set(this,void 0),bo.set(this,new ut("following",!1)),yo.set(this,null),ko.set(this,""),Co.set(this,(()=>{c(this,Gi,"m",Vo).call(this,!0)})),d(this,Yi,this.attachShadow({mode:"open"}),"f"),d(this,so,c(this,bo,"f").value,"f")}attributeChangedCallback(e,t,i){switch(e){case R:d(this,Xi,i,"f"),c(this,Gi,"m",Vo).call(this);break;case H:d(this,Ji,i,"f"),c(this,Gi,"m",Vo).call(this);break;case K:d(this,Zi,i,"f"),Ie(c(this,Zi,"f"));break;case tt:d(this,eo,"true"===i,"f"),c(this,Gi,"m",Vo).call(this)}}connectedCallback(){return h(this,void 0,void 0,(function*(){this.subscribeToHub(Ve.UserStatusIdentity,c(this,Co,"f")),yield c(this,Gi,"m",So).call(this),c(this,Gi,"m",Mo).call(this),c(this,Gi,"m",xo).call(this)}))}disconnectedCallback(){var e,t,i,o;this.unsubscribeAllFromHub(),null===(e=c(this,ro,"f"))||void 0===e||e.destroy(),null===(t=c(this,io,"f"))||void 0===t||t.disconnect(),null===(i=c(this,co,"f"))||void 0===i||i.destroy(),null===(o=c(this,uo,"f"))||void 0===o||o.destroy()}}Yi=new WeakMap,Qi=new WeakMap,Ji=new WeakMap,Xi=new WeakMap,Zi=new WeakMap,eo=new WeakMap,to=new WeakMap,io=new WeakMap,oo=new WeakMap,so=new WeakMap,no=new WeakMap,ao=new WeakMap,ro=new WeakMap,lo=new WeakMap,ho=new WeakMap,co=new WeakMap,uo=new WeakMap,po=new WeakMap,mo=new WeakMap,_o=new WeakMap,fo=new WeakMap,go=new WeakMap,wo=new WeakMap,vo=new WeakMap,bo=new WeakMap,yo=new WeakMap,ko=new WeakMap,Co=new WeakMap,Gi=new WeakSet,So=function(){return h(this,void 0,void 0,(function*(){try{const e="en",t={follow_on_shop:{follow:"Follow on {shop}",following:"Following on {shop}",auth_modal:{title:"Follow on Shop",description:"Stay in the know—never miss a sale, restock, or order update."},following_modal:{title:"Visit {store} on Shop",subtitle:"Everything you need to shop, track, and pay—all in one place.",qr_header:"Scan to visit {store} on the Shop app",qr_alt_text:"Shop app QR code",continue:"Continue"},completed:{title:"You're following {store}",subtitle:"We've sent you an email with a link to download the Shop app."},personalization_consent:{title:"To follow on Shop, sync your shopping activity"}},login_with_shop:{login:"Sign in with {shop}",auth_modal:{login_title:"Sign in with Shop",login_title_with_store:"Sign in to {store} with Shop",login_description:"The easiest and most secure way to sign in to {store}—no password needed.",signup_title:"Create an account",signup_description:"Enter your phone number to create a Shop account.",login_sms_title:"Confirm it's you",login_sms_description:"Enter the code sent to {phoneNumber}",login_email_title:"Confirm it’s you",login_email_description:"Enter the code sent to your email, {email}",login_webauthn_title:"Confirm it’s you",login_webauthn_description:"Sign in with a passkey to securely use your saved information.",login_webauthn_footer:"By continuing, your name and email address will be shared with {store}."}},verified_email_auth:{auth_modal:{login_title:"Log in or sign up",signup_title:"Continue with Shop",signup_description:"Create a Shop account to sign in to {clientName}–no passwords needed"}},legal:{terms_of_service:"terms of service",privacy_policy:"privacy policy",terms:"terms",client:"See {clientName}’s {termsOfService} and {privacyPolicy}.",shop:"By continuing, you agree to Shop’s {termsOfService} and acknowledge the {privacyPolicy}.",authorized_scopes:{email_name:"By continuing, your name and email address will be shared with {store}."}},checkout_modal:{auth_modal:{login_sms_description:"Enter the code sent to {phoneNumber} to securely use your saved information.",login_email_description:"Enter the code sent to your email, {email} to securely use your saved information."}},customer_accounts:{remember_me:"Save my info securely with Shop to sign in faster everywhere",sign_up_page:{auth_modal:{login_title:"Continue with Shop",login_description:"Use your Shop account to sign in everywhere—no password needed.",login_sms_description:"Use your Shop account to sign in everywhere—no password needed.\r\n\r\nConfirm it's you, enter the code sent to {phoneNumber}",login_email_description:"Use your Shop account to sign in everywhere—no password needed.\r\n\r\nConfirm it's you, enter the code sent to your email, {email}",login_webauthn_title:"Continue with Shop",login_webauthn_description:"Sign in with a passkey to securely use your saved information."}}},payment_request:{auth_modal:{login_title:"Check out with Shop Pay",login_description:"Use your saved information to check out securely at {store}.",login_sms_title:"Confirm it's you",login_sms_description:"Enter the code sent to {phoneNumber} to securely use your saved information.",login_email_title:"Confirm it’s you",login_email_description:"Enter the code sent to your email, {email} to securely use your saved information."}}};d(this,yo,new u({[e]:t}),"f")}catch(e){e instanceof Error&&p.notify(e)}return null}))},Mo=function(){d(this,oo,function(e){const t=document.createElement("follow-on-shop-button");return e&&t.setAttribute(Vi,""),t}(c(this,so,"f")),"f"),c(this,Yi,"f").innerHTML=pt,c(this,Yi,"f").appendChild(c(this,oo,"f"))},xo=function(){var e;c(this,Gi,"m",$o).call(this,c(this,so,"f")),c(this,Gi,"m",Uo).call(this),Ie(c(this,Zi,"f")),null===(e=c(this,oo,"f"))||void 0===e||e.addEventListener("click",(()=>{var e;if(c(this,eo,"f"))return d(this,so,!c(this,so,"f"),"f"),void(null===(e=c(this,oo,"f"))||void 0===e||e.setFollowing({following:c(this,so,"f")}));c(this,so,"f")?(c(this,to,"f").trackFollowingGetAppButtonPageImpression(),mt()?c(this,Gi,"m",Eo).call(this):c(this,Gi,"m",Io).call(this)):(c(this,to,"f").trackFollowButtonClicked(),c(this,Gi,"m",To).call(this))}))},To=function(){c(this,po,"f")?c(this,Gi,"m",Do).call(this):(d(this,mo,c(this,Gi,"m",Ao).call(this),"f"),d(this,_o,Ii({}),"f"),c(this,_o,"f").append(c(this,Gi,"m",Lo).call(this)),d(this,co,y().withInnerHTML(pt).build(),"f"),c(this,co,"f").setNametagSuffix("follow"),d(this,po,c(this,co,"f").sheetModal,"f"),c(this,po,"f").setAttribute(O,c(this,Qi,"f")),c(this,po,"f").appendChild(c(this,mo,"f")),c(this,po,"f").appendChild(c(this,_o,"f")),c(this,po,"f").addEventListener("modalcloserequest",c(this,Gi,"m",qo).bind(this)),c(this,po,"f").setMonorailTracker(c(this,to,"f")),d(this,fo,Ho.Mounting,"f"))},Eo=function(){return h(this,void 0,void 0,(function*(){var e,t,i;if(!c(this,go,"f")){d(this,uo,y().withInnerHTML(pt).build(),"f"),c(this,uo,"f").setNametagSuffix("followed"),d(this,go,c(this,uo,"f").sheetModal,"f"),c(this,go,"f").setMonorailTracker(c(this,to,"f")),c(this,go,"f").setAttribute("disable-popup","true");const o=yield c(this,Gi,"m",Wo).call(this),s=null!==(e=null==o?void 0:o.name)&&void 0!==e?e:"the store",n=null===(t=c(this,yo,"f"))||void 0===t?void 0:t.translate("follow_on_shop.following_modal.title",{store:s}),a=null===(i=c(this,yo,"f"))||void 0===i?void 0:i.translate("follow_on_shop.following_modal.subtitle");d(this,wo,Ii({title:n,description:a},!0),"f"),c(this,go,"f").appendChild(c(this,wo,"f")),c(this,go,"f").appendChild(yield c(this,Gi,"m",Oo).call(this)),c(this,go,"f").addEventListener("modalcloserequest",(()=>h(this,void 0,void 0,(function*(){var e;c(this,go,"f")&&(yield c(this,go,"f").close({reason:"user_dismissed"})),null===(e=c(this,oo,"f"))||void 0===e||e.setFocused()})))),n&&c(this,go,"f").setAttribute("title",n)}c(this,go,"f").open("user_button_clicked"),c(this,to,"f").trackFollowingGetAppButtonPageImpression()}))},Ao=function(){const e=document.createElement(Ri);return c(this,Gi,"m",Wo).call(this).then((t=>{e.update({name:(null==t?void 0:t.name)||"",logoSrc:(null==t?void 0:t.id)?`${_t}/shops/${t.id}/logo?width=58`:""})})).catch((()=>{})),e},Lo=function(){var e;d(this,ao,document.createElement("iframe"),"f"),c(this,ao,"f").tabIndex=0,c(this,Gi,"m",Vo).call(this);const t=(null===(e=this.ownerDocument)||void 0===e?void 0:e.defaultView)||void 0;return d(this,ro,new $e(new Ue(c(this,ao,"f")),[r,We,c(this,Zi,"f")],c(this,Gi,"m",Bo).bind(this),t),"f"),d(this,lo,new ze(c(this,ao,"f")),"f"),L(c(this,ao,"f"),"allow","publickey-credentials-get *"),c(this,ao,"f")},Oo=function(){return h(this,void 0,void 0,(function*(){var e,t;const i=document.createElement("div"),o=yield c(this,Gi,"m",Wo).call(this),s=null==o?void 0:o.id,n=null!==(t=null===(e=c(this,yo,"f"))||void 0===e?void 0:e.translate("follow_on_shop.following_modal.continue",{defaultValue:"Continue"}))&&void 0!==t?t:"",a=s?`https://shop.app/sid/${s}`:"#";return i.innerHTML=ft(a,n),i.addEventListener("click",(()=>h(this,void 0,void 0,(function*(){var e;c(this,to,"f").trackFollowingGetAppButtonClicked(),null===(e=c(this,go,"f"))||void 0===e||e.close({reason:"user_dismissed"})})))),i}))},Io=function(){return h(this,void 0,void 0,(function*(){var e,t,i,o,s,n,a;if(!c(this,vo,"f")){d(this,vo,document.createElement("div"),"f"),c(this,vo,"f").classList.add("fos-tooltip","fos-tooltip-hidden");const r=yield c(this,Gi,"m",Wo).call(this),l=null!==(e=null==r?void 0:r.name)&&void 0!==e?e:"the store",h=null!==(i=null===(t=c(this,yo,"f"))||void 0===t?void 0:t.translate("follow_on_shop.following_modal.qr_header",{store:l}))&&void 0!==i?i:"",u=null!==(s=null===(o=c(this,yo,"f"))||void 0===o?void 0:o.translate("follow_on_shop.following_modal.qr_alt_text"))&&void 0!==s?s:"",p=null==r?void 0:r.id,m=p?`${_t}/qr/sid/${p}`:"#";c(this,vo,"f").innerHTML=gt(h,m,u),null===(n=c(this,vo,"f").querySelector(".fos-tooltip-overlay"))||void 0===n||n.addEventListener("click",(()=>{var e;null===(e=c(this,vo,"f"))||void 0===e||e.classList.toggle("fos-tooltip-hidden",!0)})),null===(a=c(this,vo,"f"))||void 0===a||a.addEventListener("click",(()=>{var e;null===(e=c(this,vo,"f"))||void 0===e||e.classList.toggle("fos-tooltip-hidden",!0)})),c(this,Yi,"f").appendChild(c(this,vo,"f"))}c(this,vo,"f").classList.toggle("fos-tooltip-hidden",!1)}))},Vo=function(e){if(c(this,ao,"f")){const t={clientId:c(this,Ji,"f"),responseType:"code"},i=xt({version:c(this,Xi,"f"),analyticsTraceId:c(this,Qi,"f"),flow:Ee.Follow,error:c(this,ko,"f"),oauthParams:t});c(this,Gi,"m",Po).call(this),L(c(this,ao,"f"),"src",i,e),p.leaveBreadcrumb("Iframe url updated",{authorizeUrl:i},"state")}},Po=function(){c(this,Gi,"m",jo).call(this),d(this,ho,setTimeout((()=>{const e=Xe.temporarilyUnavailable;this.dispatchCustomEvent("error",{message:e.message,code:e.code}),c(this,Gi,"m",jo).call(this)}),Qe),"f")},jo=function(){c(this,ho,"f")&&(clearTimeout(c(this,ho,"f")),d(this,ho,void 0,"f"))},$o=function(e){c(this,to,"f").trackFollowButtonPageImpression(e)},Uo=function(){d(this,io,new IntersectionObserver((e=>{var t;for(const{isIntersecting:i}of e)i&&(null===(t=c(this,io,"f"))||void 0===t||t.disconnect(),c(this,to,"f").trackFollowButtonInViewport())})),"f"),c(this,io,"f").observe(c(this,oo,"f"))},Wo=function(){return h(this,void 0,void 0,(function*(){return c(this,no,"f")||d(this,no,yield wt(c(this,Zi,"f")),"f"),c(this,no,"f")}))},zo=function(e){return h(this,arguments,void 0,(function*({loggedIn:e,shouldFinalizeLogin:t,email:i,givenName:o,avatar:s}){var n,a,r,l;c(this,bo,"f").set(!0),e&&t&&(Re(c(this,Zi,"f"),(e=>{p.notify(new Error(e))})),this.publishToHub(Ve.UserSessionCreate,{email:o||i,initial:(null==o?void 0:o[0])||(null==i?void 0:i[0])||"",avatar:s})),this.dispatchCustomEvent("completed",{loggedIn:e,email:i}),yield null===(n=c(this,mo,"f"))||void 0===n?void 0:n.setFavorited(),yield null===(a=c(this,po,"f"))||void 0===a?void 0:a.close({reason:"event_completed"}),null===(r=c(this,ro,"f"))||void 0===r||r.destroy(),null===(l=c(this,oo,"f"))||void 0===l||l.setFollowing({following:!0}),d(this,so,!0,"f"),c(this,Gi,"m",$o).call(this,!0)}))},No=function(e,t,i){var o;c(this,Gi,"m",jo).call(this),e===D.RetriableServerError&&(null===(o=c(this,_o,"f"))||void 0===o||o.update({status:void 0}),d(this,ko,e,"f"),c(this,Gi,"m",Vo).call(this,!0)),this.dispatchCustomEvent("error",{code:e,message:t,email:i})},Fo=function(e){return h(this,arguments,void 0,(function*({clientName:e,logoSrc:t}){(e||t)&&c(this,mo,"f").update({name:e,logoSrc:t}),c(this,to,"f").trackShopPayModalStateChange({currentState:Ne.Loaded,reason:"event_loaded"}),c(this,fo,"f")===Ho.Mounting&&(c(this,Gi,"m",Do).call(this),d(this,fo,Ho.Open,"f"),c(this,Gi,"m",jo).call(this))}))},Do=function(){return h(this,void 0,void 0,(function*(){var e;(yield c(this,po,"f").open("user_button_clicked"))&&(null===(e=c(this,lo,"f"))||void 0===e||e.postMessage({type:"sheetmodalopened"}))}))},qo=function(){return h(this,void 0,void 0,(function*(){var e,t;if(c(this,po,"f")){(yield c(this,po,"f").close({reason:"user_dismissed"}))&&(null===(e=c(this,lo,"f"))||void 0===e||e.postMessage({type:"sheetmodalclosed"}),Ae())}null===(t=c(this,oo,"f"))||void 0===t||t.setFocused()}))},Bo=function(e){var t,i,o,s;switch(e.type){case"loaded":c(this,Gi,"m",Fo).call(this,e);break;case"resize_iframe":c(this,ao,"f").style.height=`${e.height}px`,c(this,ao,"f").style.width=`${V(e.width,c(this,ao,"f"))}px`;break;case"completed":c(this,Gi,"m",zo).call(this,e);break;case"error":c(this,Gi,"m",No).call(this,e.code,e.message,e.email);break;case"content":null===(t=c(this,po,"f"))||void 0===t||t.setAttribute("title",e.title),null===(i=c(this,_o,"f"))||void 0===i||i.update(e),null===(o=c(this,mo,"f"))||void 0===o||o.classList.toggle("hidden",e.authorizeState===at.Captcha);break;case"processing_status_updated":null===(s=c(this,_o,"f"))||void 0===s||s.update(e);break;case"close_requested":c(this,Gi,"m",qo).call(this)}},vt()&&(bt({bundle:"loginButton",bundleLocale:"en"}),pi(),q("shop-follow-button",Ro),ri(),q("shop-swirl",mi));export{Ct as C,ui as S,ri as a,xt as b,pi as d,Mt as g};
//# sourceMappingURL=client.login-button_BXY0vbFt.en.esm.js.map